# -*- coding: utf-8 -*-
"""
@Time ： 2023/10/11 21:30
@Auth ： y.h
@File ：re_df_name.py
@IDE ：PyCharm
@Motto：The sooner you start to code, the longer the program will take. —— Roy Carlson
"""

class 更改列名配置文件:
    __old_col_name = []
    __new_col_name = []

    def _get_old_col_name(self):
        return self.__old_col_name

    def 配置老列名(self,old_col_name):
        self.__old_col_name = []
        if type(old_col_name) == type(list()):
            self.__old_col_name.extend(old_col_name)
        else:
            self.__old_col_name.append(old_col_name)
        return self

    def _get_new_col_name(self):
        return self.__new_col_name

    def 配置新列名(self,new_col_name):
        self.__new_col_name = []
        if type(new_col_name) == type(list()):
            self.__new_col_name.extend(new_col_name)
        else:
            self.__new_col_name.append(new_col_name)
        return self

    def get_rename_dict(self):
        if len(self._get_new_col_name()) != len(set(self._get_new_col_name())) and len(self._get_old_col_name()) != len(set(self._get_old_col_name())):
            print("新列表或老列表内包含重复列名,建议分两次更改")
            exit(True)
        elif len(self._get_new_col_name()) == len(self._get_old_col_name()):
            result_dict = dict()
            for i in range(0,len(self._get_new_col_name())):
                result_dict.update({self._get_old_col_name()[i] : self._get_new_col_name()[i]})
            return result_dict
        else:
            print(f"老列名参数为{len(self._get_new_col_name())},新列名参数为{len(self._get_old_col_name())},参数个数错误!")
            exit(True)
